def Project_settor():
	import nuke

	node = nuke.selectedNodes('Read')
	if len(node)!=1:
		nuke.message('You are selecting 0 or more than one \"Read\" node')
	else:
		node = node[0]
		try:
			from PySide.QtCore import Qt
			from PySide.QtGui import QMainWindow, QApplication, QGridLayout, QPushButton, QWidget, QComboBox, QLineEdit, \
				QLabel, QTextEdit, QCheckBox
		except Exception as e:
			from PySide2.QtCore import Qt
			from PySide2.QtWidgets import QMainWindow, QApplication, QGridLayout, QPushButton, QWidget, QComboBox, \
				QLineEdit, QLabel, QTextEdit, QCheckBox

		def getNukeWindow():
			return QApplication.activeWindow()

		class test(QMainWindow):
			def __init__(self,par = getNukeWindow()):
				super(test,self).__init__(par)
				test.initUI(self)

				
				

			def initUI(self):
				self.setWindowTitle('Project settor')
				# self.setFixedSize(500,500/2.35)
				self.widget = QWidget()
				self.layout = QGridLayout()
				self.widget.setLayout(self.layout)

				self.fps = float(node.metadata().get('input/frame_rate') if node.metadata().get('input/frame_rate') else 24)
				self.framerange_first = node['first'].value()
				self.framerange_last = node['last'].value()
	# items			
	# --------------------------------------------------------------------------
				self.Format = QCheckBox('Format')
				self.FrameRangeFirst = QCheckBox('Framerange first')
				self.FrameRangeLast = QCheckBox('Framerange last')
				self.Fps = QCheckBox('FPS')

				self.FormatEditA = QLineEdit('1920')
				self.FormatEditB = QLineEdit('1080')
				self.FrameRangeFirstEdit = QLineEdit(str(self.framerange_first))
				self.FrameRangeLastEdit = QLineEdit(str(self.framerange_last))
				self.FpsEdit = QLineEdit(str(self.fps))

				self.SetButton = QPushButton('Set')				
	# size
	# --------------------------------------------------------------------------
				self.SetButton.setFixedHeight(35)
				self.FormatEditA.setFixedWidth(45)
				self.FormatEditB.setFixedWidth(45)
	# state
	# --------------------------------------------------------------------------
				self.Format.setChecked(True)
				self.FrameRangeFirst.setChecked(True)
				self.FrameRangeLast.setChecked(True)
				self.Fps.setChecked(True)

				self.FormatEditA.setEnabled(False)
				self.FormatEditB.setEnabled(False)
				# self.FormatQComboBox.setEnabled(False)
				self.FrameRangeFirstEdit.setEnabled(False)
				self.FrameRangeLastEdit.setEnabled(False)
				self.FpsEdit.setEnabled(False)

				self.Fps.setToolTip('Remove this to set other frame rate!')
				self.SetButton.setToolTip('This will automatically set up the \nproject depending on \nyour current selection')
	# function
	# --------------------------------------------------------------------------
				self.Format.stateChanged.connect(self.setFormatVisible)
				self.FrameRangeFirst.stateChanged.connect(self.setFirstVisible)
				self.FrameRangeLast.stateChanged.connect(self.setLastVisible)
				self.Fps.stateChanged.connect(self.setFpsVisible)

				self.SetButton.clicked.connect(self.Sets)
	# add widgets
	# --------------------------------------------------------------------------
				self.layout.addWidget(self.Format,0,0,1,2)
				self.layout.addWidget(self.FrameRangeFirst,1,0,1,2)
				self.layout.addWidget(self.FrameRangeLast,2,0,1,2)
				self.layout.addWidget(self.Fps,3,0,1,2)

				# self.layout.addWidget(self.FormatEditA,0,2,1,1)
				# self.layout.addWidget(self.FormatEditB,0,3,1,1)
				self.layout.addWidget(self.FrameRangeFirstEdit,1,2,1,2)
				self.layout.addWidget(self.FrameRangeLastEdit,2,2,1,2)
				self.layout.addWidget(self.FpsEdit,3,2,1,2)

				self.layout.addWidget(self.SetButton,4,0,4,4)

				self.setCentralWidget(self.widget)
				self.show()

			def Sets(self):

				if self.Format.isChecked():
					formats = node['format'].value()
					nuke.root()['format'].setValue(formats)

				if not self.Fps.isChecked():
					self.fps = float(self.FpsEdit.text())
				# else:
				# 	fps = float(self.FpsEdit.text())
				nuke.root()['fps'].setValue(self.fps)

				if not self.FrameRangeFirst.isChecked():
					self.framerange_first = float(self.FrameRangeFirstEdit.text())
				# else:
				# 	framerange_first = float(self.FrameRangeFirstEdit.text())
				nuke.root()['first_frame'].setValue(self.framerange_first)					

				if not self.FrameRangeLast.isChecked():
					self.framerange_last = float(self.FrameRangeLastEdit.text())
				# else:
				# 	framerange_last = float(self.FrameRangeLastEdit.text())
				nuke.root()['last_frame'].setValue(self.framerange_last)

				nuke.message('Done!')
				self.close()

			def setFpsVisible(self,state):
				self.FpsEdit.setEnabled(not state)
			
			def setFormatVisible(self,state):
				self.FormatEditA.setEnabled(not state)
				self.FormatEditB.setEnabled(not state)

			def setFirstVisible(self,state):
				self.FrameRangeFirstEdit.setEnabled(not state)

			def setLastVisible(self,state):
				self.FrameRangeLastEdit.setEnabled(not state)

		test()

